<template>
  <div>
    <div style="height:80px">
      <el-form :inline="true" class="demo-form-inline">
      <el-form-item>
        <el-input v-model="map.findid" placeholder="档案号"></el-input>
      </el-form-item>
      <el-form-item>
        <el-input v-model="map.findname" placeholder="姓名"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="selresultall()">查询</el-button>
      </el-form-item>
    </el-form>
    </div>
    <div>
        <el-table
        :data="page.rows"
        border
        style="width: 100%">
        <el-table-column
          prop="besResultId"
          label="档案号"
          width="230"
          align="center">
        </el-table-column>
        <el-table-column
          prop="besResultName"
          label="姓名"
          width="200"
          align="center">
        </el-table-column>
        <el-table-column
          prop="besResultGender"
          label="性别"
          width="160"
          align="center">
        </el-table-column>
        <el-table-column
          prop="besResultAge"
          label="年龄"
          width="180"
          align="center">
        </el-table-column>
        <el-table-column
          prop="person.perClassName"
          label="人群分类"
          width="230"
          align="center">
        </el-table-column>
        <el-table-column
          label="操作"
          width="228"
          align="center"
          prop="besResultId">
          <template slot-scope="scope">
            <el-button type="text"  v-if="scope.row.besResultConfirm == 0" @click="selresultone(scope.row.besResultId)">确认分类</el-button>
            <el-button type="text" disabled v-if="scope.row.besResultConfirm == 1">已确认分类</el-button>
          </template>
        </el-table-column>
      </el-table>
      </div>
      <div class="block">
        <el-pagination
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="currentPage"
                  :page-sizes="[3, 5, 9, 15]"
                  :page-size="pageSize"
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="page.total">
          </el-pagination>
      </div>

      <el-dialog
        title="人群分类"
        :visible.sync="visible"
        width="50%"
        center
        :before-close="clearresult">
        <div>
          <el-tabs type="border-card" v-model="activeName">
            <el-tab-pane label="基本信息" name="first" >
              <el-form ref="form" :model="result" label-width="80px">
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="档案号：">{{result.besResultId}}</el-form-item>
                    <el-form-item label="性别：">{{result.besResultGender}}</el-form-item>
                    </el-col>
                  <el-col :span="12">
                    <el-form-item label="姓名：">{{result.besResultName}}</el-form-item>
                    <el-form-item label="年龄：">{{result.besResultAge}}</el-form-item>
                  </el-col>
                </el-row>
                <el-form-item label="疾病史：">
                    {{result.member.caseHistory.memCaseHisMedical}}
                </el-form-item>
                <el-form-item label="手术史：">
                    {{result.member.caseHistory.memCaseHisOperation}}
                </el-form-item>
                <el-form-item label="家族史：">
                    {{result.member.caseHistory.memCaseHisClan}}
                </el-form-item>
              </el-form>
            </el-tab-pane>
            <el-tab-pane label="体检信息" name="second">
                <el-row style="margin-bottom: 15px">
                  <el-col :span="6">档案号</el-col>
                  <el-col :span="6">体检时间</el-col>
                  <el-col :span="6">体检套餐</el-col>
                  <el-col :span="6">体检结果</el-col>
                </el-row>
                <hr>
                <el-row style=" padding: 10px 0; margin-bottom: 15px">
                  <el-col :span="6">{{result.besId}}</el-col>
                  <el-col :span="6">{{result.bespeak.besTime}}</el-col>
                  <el-col :span="6">{{result.setMeal.besSmName}}</el-col>
                  <el-col :span="6">{{result.besResultContent}}</el-col>
                </el-row>
            </el-tab-pane>
            <el-tab-pane label="评估结果" name="third">
                <el-row>
                  <el-col :span="6">档案号</el-col>
                  <el-col :span="6">测评日期</el-col>
                  <el-col :span="6">测评内容</el-col>
                  <el-col :span="6">测评结果</el-col>
                </el-row>
                <hr>
                <el-row style="padding: 10px 0; margin-bottom: 15px ; background-color: #e5e9f2" >
                  <el-col :span="6">{{result.constitutionTest.conTestId}}</el-col>
                  <el-col :span="6">{{result.constitutionTest.conTestDatetime}}</el-col>
                  <el-col :span="6">体质测评</el-col>
                  <el-col :span="6">
                      <span v-if="result.constitutionTest.conTestPinghe == '是'"> 平和质 </span>
                      <span v-if="result.constitutionTest.conTestQixu == '是'"> 气虚质 </span>
                      <span v-if="result.constitutionTest.conTestYangxu == '是'"> 阳虚质 </span>
                      <span v-if="result.constitutionTest.conTestYinxu == '是'"> 阴虚质 </span>
                      <span v-if="result.constitutionTest.conTestTanshi == '是'"> 痰湿质 </span>
                      <span v-if="result.constitutionTest.conTestShire == '是'"> 湿热质 </span>
                      <span v-if="result.constitutionTest.conTestXueyu == '是'"> 血瘀质 </span>
                      <span v-if="result.constitutionTest.conTestQiyu == '是'"> 气郁质 </span>
                      <span v-if="result.constitutionTest.conTestTebing == '是'"> 特禀质 </span>
                  </el-col>
                </el-row>
                <el-row style="padding: 10px 0; margin-bottom: 30px ; background-color: #e5e9f2">
                  <el-col :span="6">{{result.mindTest.mindTestId}}</el-col>
                  <el-col :span="6">{{result.mindTest.mindTestDatetime}}</el-col>
                  <el-col :span="6">心理测评</el-col>
                  <el-col :span="6">
                      <span v-if="result.mindTest.mindTestQuti == '是'"> 躯体化 </span>
                      <span v-if="result.mindTest.mindTestQiangpozheng == '是'"> 强迫症 </span>
                      <span v-if="result.mindTest.mindTestRenji == '是'"> 人际关系敏感 </span>
                      <span v-if="result.mindTest.mindTestYouyu == '是'"> 犹豫 </span>
                      <span v-if="result.mindTest.mindTestJiaolv == '是'"> 焦虑 </span>
                      <span v-if="result.mindTest.mindTestDidui == '是'"> 敌对 </span>
                      <span v-if="result.mindTest.mindTestKongbu == '是'"> 恐怖 </span>
                      <span v-if="result.mindTest.mindTestPianzhi == '是'"> 偏执 </span>
                      <span v-if="result.mindTest.mindTestJingshenbing == '是'"> 精神病性 </span>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="3">档案号</el-col>
                  <el-col :span="5">测评日期</el-col>
                  <el-col :span="4">测评内容</el-col>
                  <el-col :span="4">膳食情况</el-col>
                  <el-col :span="4">运动情况</el-col>
                  <el-col :span="4">吸烟情况</el-col>
                </el-row>
                <hr>
                <el-row style=" padding: 10px 0; margin-bottom: 15px ; background-color: #e5e9f2">
                  <el-col :span="2">{{result.riskTest.riskTestId}}</el-col>
                  <el-col :span="6">{{result.riskTest.riskTestDatetime}}</el-col>
                  <el-col :span="4">健康测评</el-col>
                  <el-col :span="4">{{result.riskTest.riskTestFood}}</el-col>
                  <el-col :span="4">{{result.riskTest.riskTestKeep}}</el-col>
                  <el-col :span="4">{{result.riskTest.riskTestSmoke}}</el-col>
                </el-row>
            </el-tab-pane>
            <el-tab-pane label="确定分类" name="fourth">
              <el-form :rules="rules" ref="result" :model="result" label-width="100px" class="demo-ruleForm">
                <el-form-item label="人群分类" prop="perClassId">
                    <el-radio v-for='per in persons' :key='per.perClassId' v-model='result.perClassId' :label='per.perClassId' style="width: 100px ; height: 40px">{{per.perClassName}}</el-radio>
                </el-form-item>
                  <el-form-item label="健康管理师" prop="hmId">
                    <el-select v-model="result.hmId" placeholder="请选择">
                      <el-option v-for='hth in healths' :key='hth.hmId' :label='hth.hmName' :value='hth.hmId'></el-option>
                    </el-select>
                  </el-form-item>
              </el-form>
            </el-tab-pane>
          </el-tabs>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="clearresult()">取 消</el-button>
          <el-button type="primary" @click="queren()">确 定</el-button>
        </span>
      </el-dialog>
  </div>
</template>

<script>
import axios from 'axios'

export default ({
  name: 'personType',
  data () {
    return {
      visible: false,
      activeName: 'first',
      map: {
        index: '',
        findid: '',
        findname: ''
      },
      page: {},
      currentPage: 1,
      pageSize: 5,
      persons: [],
      result: {
        besResultId: '',
        besId: '',
        besResultName: '',
        besResultGender: '',
        besResultAge: '',
        besResultUploadId: '',
        besResultNormal: '',
        besResultContent: '',
        besResultZip: '',
        besResultHealth: '',
        besResultDel: '',
        besResultState: '',
        perClassId: '',
        besResultConfirm: '',
        hmId: '',
        member: {
          caseHistory: {
            memCaseHisMedical: '',
            memCaseHisClan: '',
            memCaseHisOperation: ''
          }
        },
        setMeal: {
          besSmName: ''
        },
        constitutionTest: {
          conTestId: '',
          conTestDatetime: '',
          conTestPinghe: '',
          conTestQixu: '',
          conTestYangxu: '',
          conTestYinxu: '',
          conTestTanshi: '',
          conTestShire: '',
          conTestXueyu: '',
          conTestTebing: ''
        },
        mindTest: {
          mindTestId: '',
          mindTestDatetime: '',
          mindTestQuti: '',
          mindTestQiangpozheng: '',
          mindTestRenji: '',
          mindTestYouyu: '',
          mindTestJiaolv: '',
          mindTestDidui: '',
          mindTestKongbu: '',
          mindTestPianzhi: '',
          mindTestJingshenbing: ''
        },
        riskTest: {
          riskTestId: '',
          riskTestDatetime: '',
          riskTestFood: '',
          riskTestKeep: '',
          riskTestSmoke: ''
        },
        bespeak: {
          besTime: ''
        }
      },
      healths: [],
      rules: {
        perClassId: [
          { required: true, message: '请选择人群分类', trigger: 'change' }
        ],
        hmId: [
          { required: true, message: '请选择健康师', trigger: 'change' }
        ]}
    }
  },
  methods: {
    selresultall () {
      this.map.index = this.currentPage
      this.map.pageSize = this.pageSize
      axios.post('/api/result/selresultall', this.map).then(result => {
        this.page = result.data
      })
    },
    // 改变页大小
    handleSizeChange (value) {
      this.pageSize = value
      this.selresultall()
    },
    // 改变当前页码
    handleCurrentChange (value) {
      this.currentPage = value
      this.selresultall()
    },
    selresultone (id) {
      axios.get('/api/result/selresultone/' + id).then(result => {
        this.result = result.data
      })
      axios.get('/api/result/selpersonall').then(result => {
        this.persons = result.data
      })
      axios.get('/api/result/selhealthall').then(result => {
        this.healths = result.data
      })
      this.visible = true
    },
    clearresult (result) {
      this.$refs.result.resetFields()
      this.visible = false
      this.activeName = 'first'
    },
    queren () {
      this.$refs.result.validate((valid) => {
        if (this.result.perClassId !== 0) {
          axios.post('/api/result/queren', this.result).then(result => {
            if (result.data) {
              this.$message({
                message: '确定分类',
                type: 'success'
              })
            } else {
              this.$message.error('分类失败，请稍后重试')
            }
            this.clearresult()
            this.selresultall()
          })
        }
      })
    }
  },
  created () {
    this.selresultall()
  }
})
</script>

<style scoped>

</style>
